<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>AdminLTE 2 | Starter</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.6 -->
  <link rel="stylesheet" href="__ADMINLTE__/bootstrap/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="__ADMINLTE__/dist/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. We have chosen the skin-blue for this starter
        page. However, you can choose any other skin. Make sure you
        apply the skin class to the body tag so the changes take effect.
  -->
  <link rel="stylesheet" href="__ADMINLTE__/dist/css/skins/skin-blue.min.css">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>

<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <!-- Main Header -->
  <include file="./Public/AdminLTE/header.html" />
  <!-- Left side column. contains the logo and sidebar -->
  <include file="./Public/AdminLTE/aside.html" />

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        General Form Elements
        <small>Preview</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">Forms</a></li>
        <li class="active">General Elements</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">

    <div class="row">
        <div class="col-xs-12">
          <div class="box box-info">
            <div class="box-header">
              <h3 class="box-title">员工列表</h3> &emsp;<button type="button" data-toggle="modal" data-target="#exampleModal" class="btn btn-sm btn-success">添加员工</button>

            </div>
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
              <table class="table table-hover">
               <tbody><tr>
                  <th>排序</th>
                  <th>姓名</th>
                  <th>所属工作组</th>
                  <th>工作状态</th>
                  <th class="text-right">操作</th>
                </tr>

        <volist name="user" id="vo">
        <tr>
    <td>{$i}</td>
    <td>{$vo.name}</td>
    <td>{$vo.workid}</td>
    <td><switch name="vo['worksta']">
        <case value="1"><span class="btn btn-success btn-xs">空闲</span></case>
        <case value="2"><span class="btn btn-danger btn-xs">工作中</span></case>
        <default />未知
        </switch></td>
    <td class="text-right">
      <a href="__CONTROLLER__/editusers/{$vo.id}" class="btn btn-warning btn-xs ajax_return">修改员工</a>
      <a href="__CONTROLLER__/del/{$vo.id}" class="btn btn-danger btn-xs ajax_return">删除</a>
    </td>
    </tr>
    </volist>

       
              </tbody></table>
            </div>
            <!-- /.box-body -->

      <div class="box-footer clearfix">
        <ul class="pagination pagination-sm no-margin pull-left">
          共有  {$data.count} 条记录
        </ul>
              <ul class="pagination pagination-sm no-margin pull-right pagelist">
              <for start="0" end="$page.pages" >
                <if condition="$page.page == $i+1"><li class="active"><a href="__APP__/admin/admin/adminlist/{$i+1}">{$i+1}</a></li>
                <else/><li><a href="__APP__/admin/admin/adminlist/{$i+1}">{$i+1}</a></li>
                </if>
              </for>
              </ul>
            </div>

          </div>
          <!-- /.box -->
        </div>
      </div>

    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  <footer class="main-footer">
    <div class="pull-right hidden-xs">
      <b>Version</b> 2.3.3
    </div>
    <strong>Copyright &copy; 2014-2015 <a href="http://almsaeedstudio.com">Almsaeed Studio</a>.</strong> All rights
    reserved.
  </footer>

</div>
<!-- ./modal -->
<div class="modal modal-success fade" id="exampleModal" role="dialog" aria-labelledby="exampleModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <form class="form-horizontal" id="addmins" method="post" action="__CONTROLLER__/adduser/">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="exampleModalLabel">新建员工</h4>
      </div>
              <div class="modal-body">
                <div class="form-group">
                  <label for="inputname" class="col-sm-2 control-label">员工姓名</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="name" id="inputname">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label">所属工作组</label>
                <div class="col-sm-10">
                    <select name="workid" class="form-control"><volist name="group" id="vo"><option value="{$vo.id}">{$vo.name}</option></volist></select>
                  </div>
                </div>
                </div>
              <!-- /.modal-body -->
              <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="submit" class="btn btn-info pull-right">确定</button>
              </div>
              <!-- /.box-footer -->
            </form>
      </div>
    </div>
  </div>

  <!-- ./modal -->
<div class="modal modal-success fade" id="edituser" role="dialog" aria-labelledby="exampleModalLabel2">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <form class="form-horizontal" id="addmins" method="post" action="__CONTROLLER__/edituser/">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="exampleModalLabel2">修改员工</h4>
      </div>
              <input type="hidden" name="id" id="userid">
              <div class="modal-body">
                <div class="form-group">
                  <label for="inputname2" class="col-sm-2 control-label">员工姓名</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="name" id="inputname2">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label">所属工作组</label>
                <div class="col-sm-10">
                    <select name="workid" id="workname" class="form-control"><volist name="group" id="vo"><option value="{$vo.id}">{$vo.name}</option></volist></select>
                  </div>
                </div>
                </div>
              <!-- /.modal-body -->
              <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="submit" class="btn btn-info pull-right">确定</button>
              </div>
              <!-- /.box-footer -->
            </form>
      </div>
    </div>
  </div>
  <!-- ./modal -->
<div class="modal modal-danger fade" id="deluser" role="dialog" aria-labelledby="exampleModalLabel3">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <form class="form-horizontal" id="addmins" method="post" action="__CONTROLLER__/deluser/">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="exampleModalLabel3">删除员工</h4>
      </div>
              <input type="hidden" name="id" id="userdelid">
              <div class="modal-body">
                确定删除用户  [<span id="userdelname"></span>]  吗？
              </div>
              <!-- /.modal-body -->
              <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="submit" class="btn btn-info pull-right">确定</button>
              </div>
              <!-- /.box-footer -->
            </form>
      </div>
    </div>
  </div>

</div>

<!-- jQuery 2.2.0 -->
<script src="__ADMINLTE__/plugins/jQuery/jQuery-2.2.0.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="__ADMINLTE__/bootstrap/js/bootstrap.min.js"></script>
<!-- AdminLTE App -->
<script src="__ADMINLTE__/dist/js/app.min.js"></script>

<script type="text/javascript">
  $(function(){

      $(".ajax_return").on("click",function(e){
        e.preventDefault();
        var url = $(this).attr("href");
        var pathurl = url.split("/");
        var id = pathurl[pathurl.length-1];
        /**修改用户**/
        if (pathurl[pathurl.length-2] == "editusers") {
            var name = $(this).parent().siblings().eq(1).text();
            var workname =$(this).parent().siblings().eq(2).text();

              $("#userid").val(id);
              $("#inputname2").val(name);
              $.get("__CONTROLLER__/getuserbyid/"+id,function(data){
                $("#workname").val(data.workid);
              });
              $("#edituser").modal('show');
        /**删除用户**/ 
        }else if(pathurl[pathurl.length-2] == "del"){
            var name = $(this).parent().siblings().eq(1).text();
            $("#userdelid").val(id);
            $("#userdelname").text(name);
            $("#deluser").modal('show');
        }else{
          
        } 
      });
  });
</script>
</body>
</html>
